﻿@{
    ViewBag.Title = "CompletedList";
}
<form method="post">
@Html.AntiForgeryToken()
<div class="querybar">
    <table cellpadding="0" cellspacing="1" border="0" width="100%">
        <tr>
            <td>
                名称：<input type="text" class="mytext" id="Title" name="Title" style="width:200px;" />
                所属流程：<select class="myselect2" style="width:150px;" id="FlowID" name="FlowID"><option value=""></option>@Html.Raw(ViewBag.FlowOptions)</select>
                发送人：<input type="text" class="mymember" id="SenderID" unit="0" dept="0" station="0" user="1" group="0" more="0" name="SenderID" />
                接收时间：<input type="text" class="mycalendar" style="width:90px;" name="Date1"/> 至 <input type="text" style="width:90px;" class="mycalendar" name="Date2" />
                <input type="button" name="Search" onclick="query(null, 1);" value="查询" class="mybutton" />
            </td>
        </tr>
    </table>
</div>
<table id="listtable"></table>
<div class="buttondiv"></div>
</form>
<script type="text/javascript">
    var curPageSize = 15;
    var curPageNumber = 1;
    $(function ()
    {
        $("#listtable").jqGrid({
            url: RoadUI.Core.rooturl() + "/WorkFlowTasks/QueryCompletedList",
            postData: { "__RequestVerificationToken": $("input[name='__RequestVerificationToken']").val() },
            mtype: 'POST',
            datatype: "json",
            colNames: ['任务标题', '流程', '步骤', '发送人', '接收时间', '完成时间', '备注', ''],
            colModel: [
                { name: 'Title', index: 'Title' },
                { name: 'FlowName', index: 'FlowID', align: "left", width: 50 },
                { name: 'StepName', index: 'StepID', align: "left", width: 80 },
                { name: 'SenderName', index: 'SenderName', align: "left", width: 50 },
                { name: 'ReceiveTime', index: 'ReceiveTime', align: "left", width: 90 },
                { name: 'CompletedTime', index: 'CompletedTime1', align: "left", width: 90 },
                
                { name: 'Note', index: 'Note', sortable: false, align: "left", width: 80 },
                { name: 'Opation', index: '', sortable: false, align: "left", width: 85 }
            ],
            sortname: "ReceiveTime",
            sortorder: "desc",
            height: '100%',
            width: $(window).width(),
            loadComplete: function ()
            {
                var gridObj = $("#listtable");
                var records = gridObj.getGridParam("userData");
                curPageSize = records.pagesize;
                curPageNumber = records.pagenumber;
                $(".buttondiv").html(RoadUI.Core.getPager1(records.total, records.pagesize, records.pagenumber, "query"));
            }
        });
    });
    $(window).resize(function ()
    {
        $("#listtable").setGridWidth($(window).width());
    });
    function query(size, number)
    {
        var data = {
            __RequestVerificationToken: $("input[name='__RequestVerificationToken']").val(),
            title: $("#Title").val(), flowid: $("#FlowID").val(),
            sender: $("#SenderID").val(), date1: $("#Date1").val(), date2: $("#Date2").val(),
            pagesize: size, pagenumber: number
        };
        $("#listtable").setGridParam({ postData: data }).trigger("reloadGrid");
    }
    function openTask(url, title, id, openModel, width, height)
    {
        top.openApp(url, openModel, title, id, width, height, false);
    }
    function detail(flowid, groupid)
    {
        top.mainDialog.open({
            url: '/WorkFlowTasks/Detail?flowid1=' + flowid + "&groupid=" + groupid + '@Html.Raw(ViewBag.query)',
            width: 1024, height: 550, title: "查看流程处理过程", opener:window
        });
    }
    function withdraw(taskID)
    {
        if (confirm("您真的要收回该任务吗?"))
        {
            $.ajax({
                url: "Withdraw?taskid=" + taskID + '@Html.Raw(ViewBag.query)', cache: false, async: false, success: function (txt)
            {
                alert(txt);
                query(curPageSize, curPageNumber);
            }
            });
        }
    }
    function hasten(taskID)
    {
        top.mainDialog.open({
            url: '/WorkFlowTasks/Hasten?taskid=' + taskID + '@Html.Raw(ViewBag.query)',
            width: 600, height: 300, title: "任务催办", opener: window, openerid:"@Request.QueryString["tabid"]"
        });
    } 
</script>
